#include "Functions.h"
CString GetLastWriteTime(HANDLE hFile)
{
	CString str;
	FILETIME ftCreate, ftAccess, ftWrite,ftLocal;
	SYSTEMTIME stWrite;

	GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite);
	FileTimeToLocalFileTime(&ftWrite, &ftLocal);

	FileTimeToSystemTime(&ftLocal, &stWrite);
	str.Format(_T("%d-%02d-%02d %02d:%02d:%02d"),stWrite.wYear,
												 stWrite.wMonth, 
												 stWrite.wDay, 
												 stWrite.wHour, 
												 stWrite.wMinute, 
												 stWrite.wSecond);

	return str;
}

CString ulToStr(ULONGLONG ul)
{
	CString str;
	str.Format(_T("%I64u"),ul);
	return str;
}

CString strTowstr(PSTR pMultiByteStr)
{
	int nLenofWstr = MultiByteToWideChar(CP_ACP, 0, pMultiByteStr, -1, NULL, 0);
	wchar_t *pWstr = (wchar_t*)HeapAlloc(GetProcessHeap(), 0, nLenofWstr * sizeof(wchar_t));
	MultiByteToWideChar(CP_ACP, 0, pMultiByteStr, -1, pWstr, nLenofWstr);

	CString str(pWstr);
	HeapFree(GetProcessHeap(), 0, pWstr);

	return str;
}